import {useNavigate} from "react-router-dom";
import {useEffect, useState} from "react";
import {getApplicantInfoAPI} from "@/apis/applicant.jsx";
import {message} from "antd";


const useGetApplicantById = (id) => {

    const navigator = useNavigate();
    const [applicant, setApplicant] = useState({});
    useEffect(() => {
        const getOneApplicantById = async () => {
            const res = await getApplicantInfoAPI(id);
            if (res.code === 200) {
                setApplicant(res.data);
            }
            else if (res.code === 500) {
                message.error(res.msg);
                navigator('/backgroundManage/applicant')
            }
        }
        getOneApplicantById().then()
    }, [])
    return applicant;
}

export {
    useGetApplicantById
}